package jp.sourceforge.akjrcp.audiomerge.operation;

import java.util.List;

import jp.sourceforge.akjrcp.audiomerge.InsertAudioData;
import jp.sourceforge.akjrcp.audiomerge.AudioMergeView.DataControler;

import org.eclipse.core.commands.ExecutionException;
import org.eclipse.core.commands.operations.AbstractOperation;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;

public class NewOperation extends AbstractOperation{
	DataControler controler;
	private InsertAudioData insertAudioData;
	public NewOperation(String label,DataControler controler,InsertAudioData data) {
		super(label);
		this.controler=controler;
		this.insertAudioData=data;
	}

	@Override
	public IStatus execute(IProgressMonitor monitor, IAdaptable info)
			throws ExecutionException {
		System.out.println("execute:added");
		controler.add(insertAudioData);
		return Status.OK_STATUS;
	}

	@Override
	public IStatus redo(IProgressMonitor monitor, IAdaptable info)
			throws ExecutionException {
		System.out.println("redo:added");
		controler.add(insertAudioData);
		return Status.OK_STATUS;
	}

	@Override
	public IStatus undo(IProgressMonitor monitor, IAdaptable info)
			throws ExecutionException {
		System.out.println("undo:removed");
		controler.remove(insertAudioData);
		return Status.OK_STATUS;
	}

}
